import 'package:flutter/material.dart';
import 'collect_news_view.dart';
import 'collect_ques_view.dart';

class CollectView extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return CollectViewState();
  }
}

class CollectViewState extends State<CollectView> with TickerProviderStateMixin {
  TabController tabController;

  @override
  void initState() {
    tabController = new TabController(length: 2, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('我的收藏'),
      ),
      backgroundColor: Colors.white,
      body: Column(
        children: ListTile.divideTiles(
          tiles: [newsWidget(), examWidget()],
          context: context,
          color: Colors.black12,
        ).toList(),
      ),
    );
  }

  Widget newsWidget() {
    return ListTile(
      title: Text(
        '新闻收藏',
        style: TextStyle(
          fontSize: 16,
        ),
      ),
      trailing: Icon(Icons.chevron_right),
      onTap: () {
        Navigator.of(context).push(
          MaterialPageRoute(builder: (cxt) => CollectNewsView()),
        );
      },
    );
  }

  Widget examWidget() {
    return ListTile(
      title: Text(
        '试题收藏',
        style: TextStyle(
          fontSize: 16,
        ),
      ),
      trailing: Icon(Icons.chevron_right),
      onTap: () {
        Navigator.of(context).push(
          MaterialPageRoute(builder: (cxt) => CollectQuesView()),
        );
      },
    );
  }
}
